<?php

namespace app\index\model;

use think\Model;
use think\Session;

class Bbsdemo extends Model
{

    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    /**
     * 留言板模型
     * @author guomengtao
     */

    // 获取器修改时间格式
    public function getcreatetimeAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['refreshtime']) ? $data['createtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }
    public static function bbs()
    {
        // 查询状态为1的用户数据 并且每页显示10条数据
        $list = Bbsdemo::order('id desc')
            // ->paginate(10, false, [
            // 'page'=>input('param.page')?:1,
            //   'type'     => 'app/bootstrapNew',
            //     'var_page' => 'page',
            // ]);
            ->paginate(10);
        return $list;
    }

    public static function toadd($title,$content)
    {
        $user           = new Bbsdemo;
        $user->title     = $title;
        $user->content    = $content;
        $user->save();
        // 获取自增ID
        return $user->id;
    }


    public static function add($title,$content)
    {


        $user             = new Bbsdemo;
        $user->title      = $title;
        $user->content    = $content;
        $user->save();
        // 获取自增ID
        return $user->id;
    }


}
